home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8509 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is &Variable (declared as: char Variable[10])?
  5. Date: 02 Mar 1996 19:15:57 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar2121557@qcd.lanl.gov>
  8. References: <4gqpa1$3h9@alcor.usc.edu> <4gsdno$1bg@umbc9.umbc.edu>
  9.     <4gvlnlINNppj@anvil.ugrad.cs.ubc.ca> <DnLx2r.323@eskimo.com>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11. Mime-Version: 1.0
  12. Content-Type: text
  13. In-reply-to: scs@eskimo.com's message of Fri, 1 Mar 1996 21:01:38 GMT
  14.  
  15. In article <DnLx2r.323@eskimo.com>
  16. scs@eskimo.com (Steve Summit) writes:
  17.  
  18. <snip>
  19. SS: A client programmer might reasonably assume that the sequence
  20. SS: 
  21. SS:     abstract_t x;
  22. SS:     f(x);
  23. SS: 
  24. SS: could not modify x.  In C, this assumption is of course not valid
  25. SS: if abstract_t happens to have array type.
  26.  
  27. Sometime back in comp.std.c there was a post which demonstrated a
  28. slightly different problem with abstract_t being an array type: the
  29. following does not compile:
  30.  
  31. void g(abstract_t *z){}
  32. void f(abstract_t x){g(&x);}
  33. int main {abstract_t y={0}; f(y);}
  34.  
  35. (In that post the question was about va_list being such an abstract
  36. type, but the problem is a general one.)
  37.  
  38.  
  39. SS: 
  40. SS: As it happens, standard C does contain one abstract type which
  41. SS: is, underneath, an array: jmp_buf, from <setjmp.h>.  Because
  42. SS: setjmp() is traditionally called as
  43. SS: 
  44. SS:     jmp_buf env;
  45. SS:     setjmp(env);
  46. SS: 
  47. SS: and because setjmp() is in fact specified as accepting a
  48. SS: parameter of type jmp_buf, but since setjmp must modify its
  49. SS: argument, we are left with the peculiar requirement that jmp_buf,
  50. SS: though seemingly abstract, must be an array type.
  51. SS: 
  52.  
  53. No. The standard specifies that setjmp may be a macro. (setjmp)(env)
  54. is not legal, neither is #undef setjmp followed by setjmp(env). As a
  55. macro can modify its argument, no requirement on jmp_buf actually
  56. exists. 
  57.  
  58. Cheers
  59. Tanmoy
  60. --
  61. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  62. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  63. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  64. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  65. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  66. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  67.